
#ifndef _TTG_THREADS_EVENTS_
#define _TTG_THREADS_EVENTS_
#include "Common/Definitions.h"

namespace ttg_internal
{
	namespace threads
	{
		//Base class for any event (which is auto-reseted).
		class ThreadEvent
		{
			public:
				//Current thread begins waiting for event.
				virtual void wait() = 0;
				//Waits for event or time interval elapsing.
				//Note: time in seconds.
				virtual void wait(double time) = 0;
				//Wake waiter thread.
				virtual void rise() = 0;
				//For descendants.
				virtual ~ThreadEvent()
				{ /*noting*/ };
		};

		//Fast implementation of the event.
		//Thread doesn't sleep, it waits in while (1) loop.
		class FastEvent :public ThreadEvent
		{
			public:
				//Current thread begins waiting for event.
				virtual void wait() = 0;
				//Waits for event or time interval elapsing.
				//Note: time in seconds.
				virtual void wait(double time) = 0;
				//Wake waiter thread.
				virtual void rise() = 0;
		};

		//Classic implementation of event.
		class SlowEvent :public ThreadEvent
		{
			public:
				//Current thread begins waiting for event.
				//In case of error throws Error().
				virtual void wait() = 0;
				//Waits for event or time interval elapsing.
				//Note: time in seconds.
				virtual void wait(double time) = 0;
				//Wake waiter thread.
				//In case of error throws Error().
				virtual void rise() = 0;
		};
	}
}

#include "Win32/Win32Events.h"

namespace ttg
{
	namespace threads
	{
		typedef ttg_internal::threads::ThreadEvent ThreadEvent;
	}
}

#endif
